package com.atguigu.xuexiplus.service.impl;

import com.atguigu.xuexiplus.entity.Question;
import com.atguigu.xuexiplus.mapper.QuestionMapper;
import com.atguigu.xuexiplus.service.QuestionService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {

    private final QuestionMapper questionMapper;

    public QuestionServiceImpl(QuestionMapper questionMapper) {
        this.questionMapper = questionMapper;
    }

    @Override
    public List<Question> getRandomQuestions(String subject, Integer gradeLevel, Integer count) {
        if (count == null || count <= 0) {
            count = 10;
        }
        return questionMapper.listRandomBySubjectAndGrade(subject, gradeLevel, count);
    }
}


